<template>
	<view>
		<cu-custom :isBack="true">
			<block slot="backText">
				{{ linkage.name }}
			</block>
		</cu-custom>
		<view v-if="linkage.linkageId">
			<trigger :linkage="linkage"></trigger>
			<condition :linkage="linkage"></condition>
			<setting :linkage="linkage"></setting>
		</view>

	</view>
</template>

<script>
	import *
	as deviceLinkageApi from '@/api/iot/iotDeviceLinkageApi.js'
	import Trigger from './components/Trigger/index.vue'
	import Condition from './components/Condition/index.vue'
	import Setting from './components/Setting/index.vue'
	export default {
		name: 'DeviceLinkageInfo',
		components: {
			Trigger,
			Condition,
			Setting
		},
		data() {
			return {
				linkageId: null,
				linkage: {}
			}
		},
		onLoad(option) {
			this.initOption = option
			this.init()
		},
		computed: {
			themeConfig() {
				return this.$store.state.themeConfig
			}
		},
		methods: {
			init() {
				this.linkageId = this.initOption.linkageId
				if (this.linkageId) {
					this.getLinkage()
				}
			},
			getLinkage() {
				deviceLinkageApi.getLinkage({
					linkageId: this.linkageId
				}).then(res => {
					const {
						data
					} = res
					if (data) {
						this.linkage = data
					}
				})
			}
		}
	}
</script>

<style>
</style>
